# $Id: Makefile.am,v 1.22 2005/08/22 20:54:21 joostvb Exp $

## for some wacky reason, we _have_ to "make" in examples before
## we can successfully run "make distcheck": this works:
##
##  sh ./bootstrap && ./configure && cd examples && make && cd -
##  make distcheck
##

AUTOMAKE_OPTIONS	= gnu no-dependencies
SUBDIRS			= examples . html

PERL                    = perl

## perhaps we'd better distribute these too, like we distribute texi2html
TEXI2DVI                = texi2dvi
TEXI2PDF                = texi2pdf
DVIPS                   = dvips

## One of these 3 vars might influence the makeinfo -I flag. Probably depends
## on autotools verion used too.
##
## MAKEINFOFLAGS           = -I .. -I $(top_srcdir)
## TEXINPUTS               = $(top_srcdir)
## MAKEINFO                = makeinfo -I $(top_srcdir)

## html handled by -local hack
INSTALLDOCS             = autobook.ps autobook.pdf

MAINTAINERCLEANFILES	= INSTALL Makefile.in aclocal.m4 \
			  configure install-sh mdate-sh missing \
			  mkinstalldirs texinfo.tex $(INSTALLDOCS)

MOSTLYCLEANFILES	= autobook.dvi

CLEANFILES		= autobook.fns autobook.ps autobook.pdf

info_TEXINFOS		= autobook.texi
autobook_TEXINFOS	= $(chapters) $(examples) $(parts) $(MENUS) appendices.texi AUTHORS COPYING PLATFORMS

## we want to ship a small tarball
EXTRA_DIST		= autobook.m4 bootstrap $(parts) appendices.texi \
			  $(chapters) PLATFORMS STYLE texi2html \
			  stamp-vti split.pl

## If you want people won't need TeX to install from the tarball, use 
## below EXTRA_DIST:  the only processing done while running `make' in
## this case is generating html from texi
##
## EXTRA_DIST		= autobook.m4 autobook.dvi autobook.texi bootstrap \
## 			  part1.texi part2.texi part3.texi appendices.texi \
## 			  $(chapters) $(MENUS) PLATFORMS STYLE texi2html \
## 	                  split.pl $(INSTALLDOCS)

## @include in autobook.texi
autobook_includes       = version.texi AUTHORS PLATFORMS COPYING

BUILT_SOURCES		= autobook.texi $(MENUS)
MENUS			= $(srcdir)/part1.menu $(srcdir)/part2.menu $(srcdir)/part3.menu $(srcdir)/appendices.menu
SUFFIXES		= .info .m4 .menu .ps .pdf .texi .texinfo .txi

docdir 	                = $(datadir)/doc/$(PACKAGE)
doc_DATA 	        = AUTHORS COPYING ChangeLog NEWS README TODO \
                          $(INSTALLDOCS)

parts		= part1.texi part2.texi part3.texi

chapters	= chapters/bootstrap.texi \
		chapters/complex-project.texi \
		chapters/cygwin.texi \
		chapters/dynamic-load.texi \
		chapters/foreword.texi \
		chapters/flow-diagrams.texi \
		chapters/intro-libtool.texi \
		chapters/large-project.texi \
		chapters/libltdl.texi \
		chapters/portable-sh.texi \
		chapters/preamble.texi \
		chapters/small-project.texi \
		chapters/using-libtool.texi

examples	= \
  examples/cc-g.texi \
  examples/configure_1.texi \
  examples/convenience/configure.texi \
  examples/convenience/error_h.texi \
  examples/convenience/error.texi \
  examples/convenience/lib/Makefile.texi \
  examples/convenience/lib/source_h.texi \
  examples/convenience/lib/source.texi \
  examples/convenience/main.texi \
  examples/convenience/Makefile.texi \
  examples/convenience/replace/basename.texi \
  examples/convenience/replace/Makefile.texi \
  examples/foonly/Makefile.texi \
  examples/foonly/configure.texi \
  examples/hello/hello.texi \
  examples/hello/main.texi \
  examples/intro-hello/hello.texi \
  examples/intro-hello/main.texi \
  examples/intro-hello/trim.texi \
  examples/ltdl-loader.texi \
  examples/ltdl-module.texi \
  examples/openmode.texi \
  examples/reexec.texi \
  examples/rpl_fopen.texi \
  examples/sic-complex/modules/Makefile_1.texi \
  examples/sic-complex/modules/Makefile_2.texi \
  examples/sic-complex/modules/unknown_1.texi \
  examples/sic-complex/sic/common-h.texi \
  examples/sic-complex/sic/Makefile_1.texi \
  examples/sic-complex/sic/module_1.texi \
  examples/sic-complex/sic/module_2.texi \
  examples/sic-complex/sic/module_3.texi \
  examples/sic-complex/sic/module_4.texi \
  examples/sic-complex/sic/module_5.texi \
  examples/sic-complex/sic/module_h_1.texi \
  examples/sic-complex/src/sic_1.texi \
  examples/sic-complex/src/sic_2.texi \
  examples/sic-complex/src/sic_builtin_1.texi \
  examples/sic-complex/src/sic_builtin_2.texi \
  examples/sic-complex/src/sic_repl_1.texi \
  examples/sic-large/bootstrap.texi \
  examples/sic-large/configure_1.texi \
  examples/sic-large/configure_4.texi \
  examples/sic-large/configure_5.texi \
  examples/sic-large/doc/Makefile_1.texi \
  examples/sic-large/doc/Makefile_2.texi \
  examples/sic-large/doc/sic_1.texi \
  examples/sic-large/Makefile_1.texi \
  examples/sic-large/Makefile_2.texi \
  examples/sic-large/replace/Makefile_1.texi \
  examples/sic-large/sic/Makefile_1.texi \
  examples/sic-large/sic/Makefile_2.texi \
  examples/sic-large/tests/defs.texi \
  examples/sic-large/tests/incomplete_1.texi \
  examples/sic-large/tests/Makefile_1.texi \
  examples/sic-small/bootstrap.texi \
  examples/sic-small/config/readline.texi \
  examples/sic-small/config/sys_errlist.texi \
  examples/sic-small/replace/Makefile.texi \
  examples/sic-small/replace/strcspn_1.texi \
  examples/sic-small/sic/builtin_h_1.texi \
  examples/sic-small/sic/common_h_1.texi \
  examples/sic-small/sic/common_h_2.texi \
  examples/sic-small/sic/common_h_3.texi \
  examples/sic-small/sic/common_h_4.texi \
  examples/sic-small/sic/error_1.texi \
  examples/sic-small/sic/error_2.texi \
  examples/sic-small/sic/error_h_1.texi \
  examples/sic-small/sic/eval_h_1.texi \
  examples/sic-small/sic/list_1.texi \
  examples/sic-small/sic/list_h_1.texi \
  examples/sic-small/sic/sic_h_1.texi \
  examples/sic-small/sic/syntax_h_1.texi \
  examples/sic-small/sic/xmalloc_1.texi \
  examples/sic-small/src/sic_1.texi \
  examples/sic-small/src/sic_builtin_1.texi \
  examples/sic-small/src/sic_h_1.texi \
  examples/sic-small/src/sic_repl_1.texi \
  examples/sic-small/src/sic_syntax_1.texi \
  examples/simple-loader.texi \
  examples/simple-module.texi

M4			= @M4@
M4FLAGS			= -I$(srcdir) -P

.m4.texi:
	cd $(top_builddir) && \
	  $(M4) $(M4FLAGS) `echo $< | sed 's,.*/,,'` > $@

%.menu: $(srcdir)/%.texi
	@echo 'm4_dnl DO NOT EDIT -- automatically generated from $<' > $@
	sed '1,/^@c %\*\*start of menu/d;/^@c %\*\*end of menu/,$$d' $(srcdir)/$< >> $@

.texi.ps:
	$(TEXI2DVI) -I $(srcdir) $<
	$(DVIPS) -f < $*.dvi > $@

.texi.pdf:
	$(TEXI2PDF) -I $(srcdir) $<

all: $(INSTALLDOCS)

# depends on examples too
autobook.texi: autobook.m4 $(MENUS) $(chapters)

# make sure all @include stuff is there
# once autobook.texi is needed
autobook.ps: autobook.texi $(autobook_includes)
autobook.pdf: autobook.texi $(autobook_includes)

macro-list:
	$(PERL) $(srcdir)/split.pl `find $(srcdir) -name '*.texi' -print` \
	  > $(srcdir)/macro-list

